home *** CD-ROM | disk | FTP | other *** search
/ Die Ultimative Software-P…i Collection 1996 & 1997 / Die Ultimative Software-Pakete CD-ROM fur Atari Collection 1996 & 1997.iso / g / gnu_c / pmlsrc23.zoo / pmlsrc / catan.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-03-19  |  1.7 KB  |  83 lines

  1. /************************************************************************
  2.  *                                    *
  3.  *                N O T I C E                *
  4.  *                                    *
  5.  *            Copyright Abandoned, 1987, Fred Fish        *
  6.  *                                    *
  7.  *    This previously copyrighted work has been placed into the    *
  8.  *    public domain by the author (Fred Fish) and may be freely used    *
  9.  *    for any purpose, private or commercial.  I would appreciate    *
  10.  *    it, as a courtesy, if this notice is left in all copies and    *
  11.  *    derivative works.  Thank you, and enjoy...            *
  12.  *                                    *
  13.  *    The author makes no warranty of any kind with respect to this    *
  14.  *    product and explicitly disclaims any implied warranties of    *
  15.  *    merchantability or fitness for any particular purpose.        *
  16.  *                                    *
  17.  ************************************************************************
  18.  */
  19.  
  20.  
  21. /*
  22.  *  FUNCTION
  23.  *
  24.  *    catan   complex double precision arc tangent
  25.  *
  26.  *  KEY WORDS
  27.  *
  28.  *    catan
  29.  *    machine independent routines
  30.  *    complex functions
  31.  *    math libraries
  32.  *
  33.  *  DESCRIPTION
  34.  *
  35.  *    Computes double precision complex arc tangent of
  36.  *    a double precision complex argument.
  37.  *
  38.  *  USAGE
  39.  *
  40.  *    COMPLEX catan (z)
  41.  *    COMPLEX z;
  42.  *
  43.  *  PROGRAMMER
  44.  *
  45.  *    Fred Fish
  46.  *    Tempe, Az 85281
  47.  *    (602) 966-8871
  48.  *
  49.  *  INTERNALS
  50.  *
  51.  *    Computes complex arc tangent of z = x + j y from:
  52.  *
  53.  *        catan(z) = -j/2 * clog( (j+z) / (j-z) )
  54.  *
  55.  */
  56.  
  57. #if defined (__M68881__) && !defined (_M68881)
  58. /*# define _M68881*/
  59. #endif
  60.  
  61. #include <stdio.h>
  62. #include <math.h>
  63. #include "pml.h"
  64.  
  65.  
  66. COMPLEX catan (z)
  67. COMPLEX z;
  68. {
  69.     COMPLEX temp;
  70.     double swaptemp;
  71.  
  72.     temp.real = -z.real;
  73.     temp.imag = 1.0 - z.imag;
  74.     z.imag += 1.0;
  75.     z = cdiv (z, temp);
  76.     z = clog (z);
  77.     swaptemp = z.real;
  78.     z.real = -0.5 * z.imag;
  79.     z.imag =  0.5 * swaptemp;
  80.  
  81.     return (z);
  82. }
  83.